package org.wutopia.leocloud.domain.payment.resource;


import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wutopia.leocloud.domain.payment.application.PaymentApplicationService;
import org.wutopia.leocloud.domain.payment.domain.Payment;
import org.wutopia.leocloud.domain.payment.domain.validation.SufficientStock;
import org.wutopia.leocloud.library.common.dto.Settlement;

/**
 * 结算清单相关的资源
 *
 **/
@RequestMapping("/settlements")
@RestController
public class SettlementResource {

    @Autowired
    private PaymentApplicationService service;

    /**
     * 提交一张交易结算单，根据结算单中的物品，生成支付单
     */
    @PostMapping("/")
    public Payment executeSettlement(@Valid @SufficientStock Settlement settlement) {
        return service.executeBySettlement(settlement);
    }

}
